<table id="importGrid"></table>
<div id="importToolbar">
    <div class="searchForm">
        <a href="javascript:void(0)" onclick="Option.Reload()" class="easyui-linkbutton"
           data-options="iconCls:'icon-reload',plain:true">刷新</a>
        <div style="float: right">
            <input type="file" name="upfile" id="upfile" value=""/>
            <input type="button" style="width: 80px;height: 25px;" class="upload easyui-linkbutton" value="提交">
        </div>
        <a href="javascript:void(0)" id="loaddata" onclick="loaddata()" class="easyui-linkbutton"
           data-options="iconCls:'icon-reload',plain:true">开始导入</a>
    </div>
</div>
<!--加载js-->
<script type="text/javascript" src="/ui/point/import/script.js"></script>
<script type="text/javascript">
    function loaddata() {
        Qrck.get(PostModule + '/Import', {}, {}, function (result) {
            if (result.code == 200) {
                $('#loaddata').hide();
            }
        });
    }

    $(function () {
        $('.upload').on('click', function () {
            var fileObj = document.getElementById("upfile").files[0]; // js 获取文件对象
            if (typeof (fileObj) == "undefined" || fileObj.size <= 0) {
                alert("请选择图片");
                return;
            }
            var formFile = new FormData();
            formFile.append("action", "UploadVMKImagePath");
            formFile.append("file", fileObj); //加入文件对象
            var data = formFile;
            $.ajax({
                headers: {
                    "X-Auth-Token": $.cookie('token')
                },
                url: Qrck.baseApiUrl + PostModule + '/in',
                data: data,
                type: "Post",
                dataType: "json",
                cache: false,//上传文件无需缓存
                processData: false,//用于对data参数进行序列化处理 这里必须false
                contentType: false, //必须
                success: function (result) {
                    if (result.code == 200) {
                        Option.Reload();
                    } else {
                        $.messager.alert('警告', result.msg);
                    }

                },
                error: function (error) {
                    console.log(error);
                }
            })

        })
    });
</script>